import { Button, Card, Modal } from 'antd';
import { connect } from 'dva';
import React, { PureComponent } from 'react';
import DescriptionList from '../../../components/DescriptionList';
const { Description } = DescriptionList;

@connect(state => ({
  theme: state.theme,
  currentUser: state.user.currentUser,
}))
export default class AddModal extends PureComponent {
  render() {
    const { detailModelData, changeAddModalVisible } = this.props;

    const data = detailModelData.data;
    let text = data.deviceStatus;
    return (
      <Modal
        title="详细信息"
        style={{ top: 20 }}
        width="700px"
        onCancel={() => changeAddModalVisible(false)}
        visible={true}
        footer={[
          <Button key="back" type="primary" onClick={() => changeAddModalVisible(false)}>
            返回
          </Button>,
        ]}
      >
        <div>
          <Card bordered={false} type="inner">
            <DescriptionList title="" col={2}>
              <Description term="车机编号" style={{ width: '50%' }}>
                {data.deviceId}
              </Description>
              <Description term="设备名称" style={{ width: '50%' }}>
                {data.deviceName}
              </Description>

              <Description term="硬件版本号" style={{ width: '100%' }}>
                {data.versionHardware}
              </Description>

              <Description term="软件版本号" style={{ width: '100%' }}>
                {data.versionSoftware}
              </Description>
              <Description term="批次号" style={{ width: '50%' }}>
                {data.batchNo}
              </Description>
              <Description term="设备状态" style={{ width: '50%' }}>
                {text === 0
                  ? '出厂'
                  : text === 1
                  ? '销售'
                  : text === 2
                  ? '激活'
                  : text === 3
                  ? '替换'
                  : text === 4
                  ? '报废'
                  : null}
              </Description>
              <Description term="激活时间" style={{ width: '50%' }}>
                {data.enrollDate}
              </Description>
              <Description term="生产日期" style={{ width: '50%' }}>
                {data.produceDate}
              </Description>
              <Description term="发布日期" style={{ width: '50%' }}>
                {data.publishDate}
              </Description>
              <Description term="入库时间" style={{ width: '50%' }}>
                {data.createDate}
              </Description>
              {detailModelData.tbox ? (
                <Description term="TBOX编号" style={{ width: '50%' }}>
                  {detailModelData.tbox}
                </Description>
              ) : null}
            </DescriptionList>
          </Card>
        </div>
      </Modal>
    );
  }
}
